home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / unixlib.lha / unix / src / perror.c < prev    next >
C/C++ Source or Header  |  1995-09-05  |  533b  |  28 lines

  1. #include "amiga.h"
  2. #include <errno.h>
  3. #include <string.h>
  4. #include <unistd.h>
  5.  
  6. void perror(const char *s)
  7. {
  8.     char *err;
  9.     char amiga_err[81];
  10.  
  11.     if (s && *s) {
  12.     __write(2, s, strlen(s));
  13.     __write(2, ": ", 2);
  14.     }
  15.     if (errno > 0 && errno <= sys_nerr)
  16.     err = sys_errlist[errno];
  17.     else if (errno == -1) {
  18.     if (Fault(_OSERR, NULL, amiga_err, 81))
  19.         err = amiga_err;
  20.     else
  21.         err = "42";        /* Shouldn't appear ... */
  22.     } else
  23.     err = "Unknown error code";
  24.  
  25.     __write(2, err, strlen(err));
  26.     __write(2, "\n", 1);
  27. }
  28.